<template>
	<div class="appointment2">
		<div class="cjjTitle">酒店预约列表</div>
		 <el-button @click="add" class="addBtn" type="primary" round>新增</el-button>
		 <el-table
    :data="tableData"
    style="width: 100%">
    <el-table-column
      label="房型"
      width="120">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="图片1"
      width="180">
      <template slot-scope="scope">
          <div slot="reference" class="imgBox name-wrapper">
            <img :src="baseUrl+scope.row.img_url1"/>
          </div>
      </template>
    </el-table-column>
    <el-table-column
      label="图片2"
      width="180">
      <template slot-scope="scope">
          <div slot="reference" class="imgBox name-wrapper">
            <img :src="baseUrl+scope.row.img_url2"/>
          </div>
      </template>
    </el-table-column>
    <el-table-column
      label="图片3"
      width="180">
      <template slot-scope="scope">
          <div slot="reference" class="imgBox name-wrapper">
            <img :src="baseUrl+scope.row.img_url3"/>
          </div>
      </template>
    </el-table-column>
    <el-table-column
      label="电话"
      width="180">
      <template slot-scope="scope">
          <div slot="reference" class="imgBox name-wrapper">
           	{{scope.row.phone}}
          </div>
      </template>
    </el-table-column>
    <el-table-column label="操作">
       <template slot-scope="scope">
        <el-button
        	round
        	sortable
          size="mini"
          @click="sortUp(scope.row.orders)">上升</el-button>
          <el-button
          round
          sortable
          size="mini"
          @click="sortDown(scope.row.orders)">下降</el-button>
          <el-button
          round
          size="mini"
          @click="handleEdit(scope.row.id)"><i class="el-icon-edit"></i></el-button>
        <el-button
       	  round
          size="mini"
          type="danger"
          @click="deleteRow(scope.row.id)"><i :current-row-key="scope.row.id" class="el-icon-delete"></i></el-button>
      </template>
    </el-table-column>
  </el-table>
	</div>
</template>

<script>
	import config from "@/assets/js/config.js"
export default {
  name: 'appointment2',
  components: {
  },
  data(){
  	return{
  		 tableData: [],
  		 baseUrl:config.baseUrl
  	}
  },
  created(){
  	this.getData();
  },
   methods: {
   	getData(){
   		this.$require.get(config.hotelList).then((res)=>{
   			console.log(res);
   			this.tableData = res.data.data.rows;
   		}).catch(function(err){
   			console.log("fail");
   		})
   	},
      handleEdit(id) {
        this.$router.push({
        	name:'appointment2edit',
        	query:{id:id}
        })      
      },
      deleteData(id) {
        this.$submit.post(config.delAppointment2,{
      			id:id
      	}).then((res)=>{
      		console.log(res);
      		this.getData();
      	}).catch(function(err){
      		console.log("fail");
      	});
      },
       deleteRow(id) {
        this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        	this.deleteData(id);
          this.$message({
      			type: 'success',
            message: '删除成功!',
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });          
        });
      },
      sortUp(orders){
        this.$submit.post(config.sortAppointment2,{
      			move: 1,
      			orders:orders
      		}
      	).then((res)=>{
      		console.log(res);
      		this.getData();
      		
      	}).catch(function(err){
      		console.log("fail");
      	});
      },
      sortDown(orders){
        this.$submit.post(config.sortAppointment2,{
      			move: -1,
      			orders:orders
      		}
      	).then((res)=>{
      		console.log(res);
      		this.getData();
      		
      	}).catch(function(err){
      		console.log("fail");
      	});
      	
      	
      },
      add(){
      	this.$router.push({
      		name:'appointment2add'
      	})
      }
    }
}
</script>

<style lang="scss" scoped>
	.appointment2{
		min-width: 1200px;
    height: 100%;
		overflow: auto;
		margin-top: 5px;
		padding-left: 25px;
		.cjjTitle{
			font-size: 36px;
			font-weight: bold;
		}
		.addBtn{
		margin-top: 20px;
		width: 150px;
		background: #FF6666;
		border: #996699;
		font-size: 18px;
		transition: 1s;
	}
	.addBtn:hover{
		background: #996699;
		color: #FFFF99;
		transform: scale(1.05);
	}
	.el-button--mini{
		font-size: 16px;
	}
	.el-table{
		min-width: 1500px;
	}
	.el-table th{
		font-size: 16px;
		font-weight: bold;
		text-align: center;
	}
	.name-wrapper{
			img{
				width: 100%;
			}
		}
	}
</style>